package com.fdb.efp.nls.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.fdb.basic.framework.core.base.AbstractFrameworkService;
import com.fdb.basic.framework.core.base.DataOptionalAuthorityDao;
import com.fdb.basic.framework.core.base.FrameworkService;
import com.fdb.basic.framework.core.util.TimeUtil;
import com.fdb.efp.nls.service.dao.*;
import com.fdb.efp.nls.service.domain.*;
import com.fdb.efp.nls.service.facade.PrdInfoService;
import com.fdb.efp.nls.service.vo.*;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/**
 * <p>
 * ServiceImpl: 产品表
 * <p>
 *
 * @author fuzm
 * @date 2018-05-03
 */
@Service("prdInfoService")
public class PrdInfoServiceImpl extends AbstractFrameworkService implements PrdInfoService, FrameworkService {

	private static Logger logger = LoggerFactory.getLogger(PrdInfoServiceImpl.class);

	@Autowired
	private PrdInfoDao prdInfoDao;
	@Autowired
	private ContTempInfoDao contTempInfoDao;
	@Autowired
	private RateSchemeDetailDao rateSchemeDetailDao;
	// @Autowired
	// private TelVerifTplService telVerifTplService ;
	@Autowired
	private PrdRuleRelDao prdRuleRelDao;
	@Autowired
	private PrdCaseManageDao prdCaseManageDao;

	/**
	 * 新增操作
	 */
	@Override
	public int insertPrdInfo(PrdInfoVO inPrdInfoVo) {
		logger.debug("当前新增数据为:" + inPrdInfoVo.toString());
		int num = 0;
		try {
			PrdInfo prdInfo = new PrdInfo();
			// String prdId = this.getSequence(SequenceConstance.PRD_INFO_SEQ_ID);
			// setInsertDefaultProperty(inPrdInfoVo);
			inPrdInfoVo.setPrdId(inPrdInfoVo.getPrdCode());
			inPrdInfoVo.setCreateTime(TimeUtil.getCurrentDateTime());
			inPrdInfoVo.setLastUpdateTime(TimeUtil.getCurrentDateTime());
			// inPrdInfoVo.setPrdId(prdId);;
			beanCopy(inPrdInfoVo, prdInfo);
			num = prdInfoDao.insertPrdInfo(prdInfo);
		} catch (Exception e) {
			logger.error("新增数据发生异常!", e);
			num = -1;
		}
		logger.debug("当前新增数据条数为:" + num);
		return num;
	}

	/**
	 * 删除操作
	 */
	@Override
	public int deleteByPk(PrdInfoVO inPrdInfoVo) {
		logger.debug("当前删除数据条件为:" + inPrdInfoVo);
		int num = 0;
		try {
			PrdInfo prdInfo = new PrdInfo();
			beanCopy(inPrdInfoVo, prdInfo);
			num = prdInfoDao.deleteByPk(prdInfo);
		} catch (Exception e) {
			logger.error("删除数据发生异常!", e);
			num = -1;
		}
		logger.debug("根据条件:" + inPrdInfoVo + "删除的数据条数为" + num);
		return num;
	}

	/**
	 * 更新操作
	 */
	@Override
	public int updateByPk(PrdInfoVO inPrdInfoVo) {
		logger.debug("当前修改数据为:" + inPrdInfoVo.toString());
		int num = 0;
		try {
			PrdInfo prdInfo = new PrdInfo();
			setUpdateDefaultProperty(inPrdInfoVo);
			beanCopy(inPrdInfoVo, prdInfo);
			num = prdInfoDao.updateByPk(prdInfo);
		} catch (Exception e) {
			logger.error("修改数据发生异常!", e);
			num = -1;
		}
		logger.debug("根据条件:" + inPrdInfoVo + "修改的数据条数为" + num);
		return num;
	}

	/**
	 * 查询操作
	 */
	@Override
	public PrdInfoVO queryByPk(PrdInfoVO inPrdInfoVo) {
		logger.debug("当前查询参数信息为:" + inPrdInfoVo);
		PrdInfo queryPrdInfo = new PrdInfo();
		beanCopy(inPrdInfoVo, queryPrdInfo);
		PrdInfo queryRslPrdInfo = prdInfoDao.queryByPk(queryPrdInfo);
		if (Objects.nonNull(queryRslPrdInfo)) {
			PrdInfoVO outPrdInfoVo = beanCopy(queryRslPrdInfo, new PrdInfoVO());
			logger.debug("当前查询结果为:" + outPrdInfoVo.toString());
			return outPrdInfoVo;
		} else {
			logger.debug("当前查询结果为空!");
			return null;
		}

	}

	@Override
	public PrdInfoVO queryByPrdCode(PrdInfoVO inPrdInfoVo) {
		logger.debug("当前查询参数信息为:" + inPrdInfoVo);
		PrdInfo queryPrdInfo = new PrdInfo();
		beanCopy(inPrdInfoVo, queryPrdInfo);
		PrdInfo queryRslPrdInfo = prdInfoDao.queryByPrdCode(queryPrdInfo);
		if (Objects.nonNull(queryRslPrdInfo)) {
			PrdInfoVO outPrdInfoVo = beanCopy(queryRslPrdInfo, new PrdInfoVO());
			logger.debug("当前查询结果为:" + outPrdInfoVo.toString());
			return outPrdInfoVo;
		} else {
			logger.debug("当前查询结果为空!");
			return null;
		}

	}

	/**
	 * 查询用户权限数据
	 */
	@Override
	@SuppressWarnings("unchecked")
	public List<PrdInfoVO> queryAllOwner(PrdInfoVO prdInfoVo) {

		logger.debug("当前查询本人所属数据信息的参数信息为:");
		PrdInfo prdInfo = beanCopy(prdInfoVo, new PrdInfo());
		List<PrdInfoVO> list = null;
		try {
			List<PrdInfo> prdInfos = prdInfoDao.queryAllOwnerByPage(prdInfo);
			logger.debug("当前查询本人所属数据信息的结果集数量为:" + prdInfos.size());
			pageSet(prdInfos, prdInfo);
			list = (List<PrdInfoVO>) beansCopy(prdInfos, PrdInfoVO.class);
		} catch (Exception e) {
			logger.error("数据转换出现异常!", e);
		}

		return list;

	}

	/**
	 * 查询当前机构权限数据
	 */
	@Override
	@SuppressWarnings("unchecked")
	public List<PrdInfoVO> queryAllCurrOrg(PrdInfoVO prdInfoVo) {

		logger.debug("当前查询本人所属机构数据信息的参数信息为:");
		PrdInfo prdInfo = beanCopy(prdInfoVo, new PrdInfo());
		List<PrdInfo> prdInfos = prdInfoDao.queryAllCurrOrgByPage(prdInfo);
		logger.debug("当前查询本人所属机构数据信息的结果集数量为:" + prdInfos.size());
		List<PrdInfoVO> list = null;
		try {
			pageSet(prdInfos, prdInfo);
			list = (List<PrdInfoVO>) beansCopy(prdInfos, PrdInfoVO.class);
		} catch (Exception e) {
			logger.error("数据转换出现异常!", e);
		}

		return list;

	}

	/**
	 * 查询当前机构及下属机构权限数据
	 */
	@Override
	@SuppressWarnings("unchecked")
	public List<PrdInfoVO> queryAllCurrDownOrg(PrdInfoVO prdInfoVo) {

		logger.debug("当前查询本人所属机构及以下数据信息的参数信息为:");
		PrdInfo prdInfo = beanCopy(prdInfoVo, new PrdInfo());
		List<PrdInfo> prdInfos = prdInfoDao.queryAllCurrDownOrgByPage(prdInfo);
		logger.debug("当前查询本人所属机构及以下数据信息的结果集数量为:" + prdInfos.size());
		List<PrdInfoVO> list = null;
		try {
			pageSet(prdInfos, prdInfo);
			list = (List<PrdInfoVO>) beansCopy(prdInfos, PrdInfoVO.class);
		} catch (Exception e) {
			logger.error("数据转换出现异常!", e);
		}

		return list;

	}

	/**
	 * 根据产品编号查询对应产品的最新版本产品信息
	 */
	@Override
	public PrdInfoVO queryLastPrdInfo(PrdInfoVO prdInfoVo) {
		logger.debug("当前查询参数信息为:" + prdInfoVo);
		try {
			PrdInfo queryPrdInfo = new PrdInfo();
			beanCopy(prdInfoVo, queryPrdInfo);
			PrdInfo queryRslPrdInfo = prdInfoDao.queryLastPrdInfo(queryPrdInfo);
			if (Objects.nonNull(queryRslPrdInfo)) {
				PrdInfoVO outPrdInfoVo = beanCopy(queryRslPrdInfo, new PrdInfoVO());
				logger.debug("当前查询结果为:" + outPrdInfoVo.toString());
				return outPrdInfoVo;
			} else {
				logger.debug("当前查询结果为空!");
				return null;
			}
		} catch (Exception e) {
			logger.error("查询数据发生异常!", e);
			return null;
		}

	}

	/**
	 * 根据产品编号查询对应的有效产品信息
	 */
	@Override
	public PrdInfoVO queryValidPrdInfo(PrdInfoVO prdInfoVo) {
		logger.debug("当前查询参数信息为:" + prdInfoVo);
		try {
			PrdInfo queryPrdInfo = new PrdInfo();
			beanCopy(prdInfoVo, queryPrdInfo);
			PrdInfo queryRslPrdInfo = prdInfoDao.queryValidPrdInfo(queryPrdInfo);
			if (Objects.nonNull(queryRslPrdInfo)) {
				PrdInfoVO outPrdInfoVo = beanCopy(queryRslPrdInfo, new PrdInfoVO());
				logger.debug("当前查询结果为:" + outPrdInfoVo.toString());
				return outPrdInfoVo;
			} else {
				logger.debug("当前查询结果为空!");
				return null;
			}
		} catch (Exception e) {
			logger.error("查询数据发生异常!", e);
			return null;
		}

	}

	/**
	 * 将产品申请对象copy到产品信息
	 */
	@Override
	public PrdInfoVO buildPrdInfoVO(PrdInfoApplyVO prdInfoApplyVo) {
		try {
			PrdInfoVO prdInfoVO = new PrdInfoVO();
			beanCopy(prdInfoApplyVo, prdInfoVO);
			// prdInfoVO.setPrdStatus(ConsoleConstant.PRD_STATUS_02);//已生效
			// prdInfoVO.setEffictiveDate(prdInfoApplyVo.getOpenDay());//生效日期
			return prdInfoVO;
		} catch (Exception e) {
			logger.error("查询数据发生异常!", e);
			return null;
		}

	}

	/**
	 * 查询所有生效产品列表
	 */
	@Override
	@SuppressWarnings("unchecked")
	public List<PrdInfoVO> queryPrdInfoSeletor(PrdInfoVO prdInfoVo) {
		logger.debug("当前查询参数信息为:" + prdInfoVo);
		List<PrdInfoVO> list = null;
		try {
			PrdInfo queryPrdInfo = beanCopy(prdInfoVo, new PrdInfo());
			List<PrdInfo> prdInfos = prdInfoDao.queryPrdInfoSeletorByPage(queryPrdInfo);
			logger.debug("当前查询当前登录用户的 法人机构 下产品数量为:" + prdInfos.size());
			try {
				pageSet(prdInfos, queryPrdInfo);
				list = (List<PrdInfoVO>) beansCopy(prdInfos, PrdInfoVO.class);
			} catch (Exception e) {
				logger.error("数据转换出现异常!", e);
			}
		} catch (Exception e) {
			logger.error("查询数据发生异常!", e);
		}
		return list;
	}

	/**
	 * 产品配置查询
	 *
	 * @param prdId
	 *            产品ID
	 * @param contTemplate
	 *            合同模板清单
	 * @param modContForm
	 *            提额合同模板清单
	 * @param creditForm
	 *            授信审批表单
	 * @param rateScheme
	 *            支用方案
	 * @param eleNucForm
	 *            电核表单
	 * @param crdApprFlow
	 *            业务流转
	 * @param crdMeaMedol
	 *            额度测算
	 * @param amtApprFlow
	 *            提额流程
	 * @param amtMeaMedol
	 *            提额测算模型
	 *
	 */
	@Override
	@SuppressWarnings("unchecked")
	public PrdInfoVO queryPrdInfo(PrdParamVO prdParamVO) {
		logger.debug("当前查询参数信息为:" + prdParamVO);
		PrdInfoVO prdInfoVo = null;
		try {
			String prdId = prdParamVO.getPrdId();
			PrdInfoVO inPrdInfoVo = new PrdInfoVO();
			inPrdInfoVo.setPrdId(prdId);
			// 产品信息
			prdInfoVo = this.queryByPk(inPrdInfoVo);
			// 获取产品关联信息对象
			if (Objects.nonNull(prdInfoVo)) {
				// 合同模板
				if (prdParamVO.isContTemplate()) {
					String contTemplateId = prdInfoVo.getContTemplateId();// 合同组模板ID
					// 查询合同组关联的合同模板
					ContTempGVO contTempGVO = new ContTempGVO();
					contTempGVO.setContGroupId(contTemplateId);
					List<ContTempInfo> contTempInfos = contTempInfoDao.queryLinkedGontTempInfosByPage(contTempGVO);
					if (contTempInfos.size() != 0) {
						List<ContTempInfoVO> ctiVOList = new ArrayList<ContTempInfoVO>();
						ContTempInfoVO ctiVO = null;
						for (ContTempInfo cti : contTempInfos) {
							ctiVO = new ContTempInfoVO();
							beanCopy(cti, ctiVO);
							ctiVOList.add(ctiVO);
						}
						prdInfoVo.setListContTempInfo(ctiVOList);
					}
				}
				// 支用方案
				if (prdParamVO.isRateScheme()) {
					String rateSchemeId = prdInfoVo.getRateSchemeId();// 支用利率方案
					// 查询关联支用方案
					RateSchemeDetail rateSchemeDetailVO = new RateSchemeDetail();
					rateSchemeDetailVO.setSchemeNo(rateSchemeId);
					List<RateSchemeDetail> rateSchemeDetails = rateSchemeDetailDao.queryByschemeNo(rateSchemeDetailVO);
					if (rateSchemeDetails.size() != 0) {
						List<RateSchemeDetailVO> rsdVOList = new ArrayList<RateSchemeDetailVO>();
						RateSchemeDetailVO rsdVO = null;
						for (RateSchemeDetail rsd : rateSchemeDetails) {
							rsdVO = new RateSchemeDetailVO();
							beanCopy(rsd, rsdVO);
							rsdVOList.add(rsdVO);
						}
						prdInfoVo.setListRateSchemeDetail(rsdVOList);
					}
				}

				// 产品规则关联信息
				if (prdParamVO.isRuleData()) {
					PrdRuleRelVO relVO = new PrdRuleRelVO();
					relVO.setPrdId(prdId);
					List<PrdRuleRel> list = prdRuleRelDao.queryAllByPrdId(relVO);
					// 转换
					List<PrdRuleRelVO> relVOList = (List<PrdRuleRelVO>) beansCopy(list, PrdRuleRelVO.class);
					prdInfoVo.setListPrdRuleRelVO(relVOList);
				}

			} else {
				logger.debug("当前查询结果为空!");
			}
		} catch (Exception e) {
			logger.error("查询数据发生异常!", e);
		}
		return prdInfoVo;
	}

	/**
	 * 根据产品编号、期限查询产品利率
	 */
	@Override
	public PrdInfoVO queryPrdInfoRate(String prdId, String term) {
		logger.debug("当前查询参数信息为prdId:" + prdId + ",term:" + term);
		PrdInfoVO outPrd = null;
		if (StringUtils.isEmpty(prdId) || "null".equals(prdId.trim())) {
			return null;
		}
		if (StringUtils.isEmpty(prdId) || "null".equals(prdId.trim())) {
			return null;
		}
		try {
			PrdInfo queryPrdInfo = new PrdInfo();
			queryPrdInfo.setPrdId(prdId);
			PrdInfo queryRslPrdInfo = prdInfoDao.queryByPk(queryPrdInfo);
			String rateSchemeId = queryRslPrdInfo.getRateSchemeId();
			if (Objects.nonNull(queryRslPrdInfo)) {
				outPrd = new PrdInfoVO();
				PrdInfoVO outPrdInfoVo = beanCopy(queryRslPrdInfo, outPrd);
				// 获取对应利率
				RateSchemeDetailVO rsdVO = new RateSchemeDetailVO();
				rsdVO.setSchemeNo(rateSchemeId);
				rsdVO.setTerm(term);
				RateSchemeDetail rsd = rateSchemeDetailDao.queryByschemeNoTerm(rsdVO);
				beanCopy(rsd, rsdVO);
				outPrd.setRateSchemeDetail(rsdVO);
				logger.debug("当前查询结果为:" + outPrdInfoVo.toString());
				return outPrdInfoVo;
			} else {
				logger.debug("当前查询结果为空!");
			}
		} catch (Exception e) {
			logger.error("查询数据发生异常!", e);
		}
		return outPrd;
	}

	/**
	 * 根据合同模板组、利率方案、电核组问题、额度测算、业务流转编号查询是否被产品关联
	 */
	@Override
	@SuppressWarnings("unchecked")
	public List<PrdInfoVO> queryPrdInfoByOthers(PrdInfoVO inPrdInfoVO) {
		logger.debug("当前查询本人所属数据信息的参数信息为:");
		PrdInfo prdInfo = beanCopy(inPrdInfoVO, new PrdInfo());
		List<PrdInfoVO> list = null;
		try {
			List<PrdInfo> prdInfos = prdInfoDao.queryPrdInfoByOthers(prdInfo);
			logger.debug("当前查询本人所属数据信息的结果集数量为:" + prdInfos.size());
			list = (List<PrdInfoVO>) beansCopy(prdInfos, PrdInfoVO.class);
		} catch (Exception e) {
			logger.error("数据转换出现异常!", e);
		}

		return list;
	}

	/**
	 * 查询产品规则关联信息
	 *
	 * @param prdId
	 * @param ruleCollType
	 * @return
	 */
	@Override
	public PrdRuleRelVO queryPrdRuleRel(String prdId, String ruleCollType) {
		try {
			PrdRuleRel paramRelVO = new PrdRuleRel();
			paramRelVO.setPrdId(prdId);
			paramRelVO.setRuleCollType(ruleCollType);
			PrdRuleRel ruleRel = prdRuleRelDao.queryByPrdIdAndRuleCollType(paramRelVO);
			// 转换
			PrdRuleRelVO ruleRelVO = beanCopy(ruleRel, new PrdRuleRelVO());
			return ruleRelVO;
		} catch (Exception e) {
			logger.error("数据转换出现异常!", e);
			return null;
		}


	}

	@Override
	public PrdInfoVO queryPrdInfo4LmtApply(String prdCode, String term) {
		logger.info("获取最新的产品信息，prdCode=" + prdCode + "，term=" + term);
		PrdInfoVO retPrdInfoVO = null;
		PrdInfo prdInfo = new PrdInfo();
		prdInfo.setPrdCode(prdCode);// 产品编号
		prdInfo = prdInfoDao.queryLastPrdInfo(prdInfo);
		if (Objects.nonNull(prdInfo)) {
			retPrdInfoVO = new PrdInfoVO();
			beanCopy(prdInfo, retPrdInfoVO);
			// 查询是否有生效的专案
			PrdCaseManageVO prdCaseManageVo = new PrdCaseManageVO();
			prdCaseManageVo.setPrdCode(prdCode);
			List<PrdCaseManage> prdCaseManages = prdCaseManageDao.queryPrdCaseManageByPrdCode(prdCaseManageVo);
			// 一个产品只有一个生效的专案
			PrdCaseManage prdCaseManage = Objects.isNull(prdCaseManages) || prdCaseManages.size() == 0 ? null : prdCaseManages.get(0);
			// 如果有生效的专案，取专案的还款方式和利率方案
			if (Objects.nonNull(prdCaseManage)) {
				logger.info("产品存在有效的专案配置，取专案的还款方式和利率方案。prdCaseManage=" + JSONObject.toJSONString(prdCaseManage));
				retPrdInfoVO.setRepayWay(prdCaseManage.getRepayWay());// 还款方式
				retPrdInfoVO.setRateSchemeId(prdCaseManage.getRateSchemeId());// 利率方案
				retPrdInfoVO.setCaseCode(prdCaseManage.getCaseCode());// 专案代码
				retPrdInfoVO.setCaseName(prdCaseManage.getCaseName());// 专案名称
			}
			// 获取对应利率
			String rateSchemeId = retPrdInfoVO.getRateSchemeId();// 利率方案ID
			RateSchemeDetailVO rateSchemeDetailVO = new RateSchemeDetailVO();
			rateSchemeDetailVO.setSchemeNo(rateSchemeId);
			rateSchemeDetailVO.setTerm(term);
			RateSchemeDetail rateSchemeDetail = rateSchemeDetailDao.queryByschemeNoTerm(rateSchemeDetailVO);
			beanCopy(rateSchemeDetail, rateSchemeDetailVO);
			retPrdInfoVO.setRateSchemeDetail(rateSchemeDetailVO);
		}
		return retPrdInfoVO;
	}

	@Override
	public List<String> queryRuleCollQuotePrdId(String ruleCollId) {
		return prdInfoDao.queryRuleCollQuotePrdId(ruleCollId);
	}

	@Override
	public DataOptionalAuthorityDao getDataAuthorityDao() {
		return this.prdInfoDao;
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<PrdInfoVO> queryPrdType(PrdInfoVO prdInfoVo) {
		// TODO Auto-generated method stub
		logger.debug("当前查询参数信息为:" + prdInfoVo);
		List<PrdInfoVO> list = null;
		try {
			List<PrdInfo> queryPrdType = prdInfoDao.queryPrdType(prdInfoVo);
			logger.debug("当前查询本人所属数据信息的结果集数量为:" + queryPrdType.size());
			list = (List<PrdInfoVO>) beansCopy(queryPrdType, PrdInfoVO.class);
		} catch (Exception e) {
			logger.error("数据转换出现异常!", e);
		}

		return list;
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<PrdInfoVO> queryAllPrdInfoList(PrdInfoVO prdInfoVo) {
		logger.debug("分页查询数据信息的参数信息为:");
		PrdInfo prdInfo = beanCopy(prdInfoVo, new PrdInfo());
		List<PrdInfoVO> list = null;
		try {
			List<PrdInfo> prdInfos = prdInfoDao.queryAllPrdInfoByPage(prdInfo);
			logger.debug("分页查询数据信息的结果集数量为:" + prdInfos.size());
			pageSet(prdInfos, prdInfo);
			list = (List<PrdInfoVO>) beansCopy(prdInfos, PrdInfoVO.class);
		} catch (Exception e) {
			logger.error("数据转换出现异常!", e);
		}
		return list;
	}

	@Override
	public PrdInfoVO queryAmt(String prdCode) {
		logger.info("当前查询条件为：" + prdCode);
		PrdInfo queryRsPrdInfo = prdInfoDao.queryAmt(prdCode);
		if (Objects.nonNull(queryRsPrdInfo)) {
			PrdInfoVO outPrdInfoVO = beanCopy(queryRsPrdInfo, new PrdInfoVO());
			logger.debug("当前查询结果为:"+ outPrdInfoVO.toString());
			return outPrdInfoVO;
		} else {
			logger.debug("当前查询结果为空!");
		}
		return null;
	}

	@Override
	public List<PrdInfoVO> queryAllEligible(PrdInfoVO prdInfoVO) {
		PrdInfo o = beanCopy(prdInfoVO, new PrdInfo());

		List<PrdInfo> prdInfos = this.prdInfoDao.queryAllEligible(o);

		if (prdInfos == null || prdInfos.size() < 1) {
			return null;
		}
		try {
			return (List<PrdInfoVO>) beansCopy(prdInfos, PrdInfoVO.class);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}

	/**
	 * 按照当前产品种类查询
	 * @param prdInfoVo
	 * @return
	 */
	@Override
	public List<PrdInfoVO> queryAllCurrOwnerPrd(PrdInfoVO prdInfoVo) {
		logger.debug("按照当前产品种类查询的参数信息为:");
		PrdInfo prdInfo = beanCopy(prdInfoVo, new PrdInfo());
		List<PrdInfoVO> list = null;
		try {
			List<PrdInfo> prdInfos = prdInfoDao.queryAllCurrOwnerPrdByPage(prdInfo);
			logger.info("按照当前产品种类查询的结果集数量为:" + prdInfos.size());
			pageSet(prdInfos, prdInfo);
			list = (List<PrdInfoVO>) beansCopy(prdInfos, PrdInfoVO.class);
		} catch (Exception e) {
			logger.error("数据转换出现异常!", e);
		}
		return list;
	}

	/*@Override
	public List<PrdInfoVO> queryAllEligible(PrdInfoVO prdInfoVO) {

		PrdInfo o = beanCopy(prdInfoVO, new PrdInfo());

		List<PrdInfo> prdInfos = this.prdInfoDao.queryAllEligible(o);

		if (prdInfos == null || prdInfos.size() < 1) {
			return null;
		}
		try {
			return (List<PrdInfoVO>) beansCopy(prdInfos,PrdInfoVO.class);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}*/

	/**
	 * 查询所有生效产品列表
	 */
	@Override
	@SuppressWarnings("unchecked")
	public List<PrdInfoVO> queryPrdInfoByPrd(PrdInfoVO prdInfoVo) {
		logger.debug("当前查询参数信息为:" + prdInfoVo);
		List<PrdInfoVO> list = null;
		try {
			PrdInfo queryPrdInfo = beanCopy(prdInfoVo, new PrdInfo());
			List<PrdInfo> prdInfos = prdInfoDao.queryPrdAccPrdByPage(queryPrdInfo);
			logger.debug("当前查询当前登录用户的 法人机构 下产品数量为:" + prdInfos.size());
			try {
				pageSet(prdInfos, queryPrdInfo);
				list = (List<PrdInfoVO>) beansCopy(prdInfos, PrdInfoVO.class);
			} catch (Exception e) {
				logger.error("数据转换出现异常!", e);
			}
		} catch (Exception e) {
			logger.error("查询数据发生异常!", e);
		}
		return list;
	}

    @Override
    public List<PrdInfoVO> listByGuarWay(String guarWay) {
        try {
            return (List<PrdInfoVO>) beansCopy(prdInfoDao.listByGuarWay(guarWay), PrdInfoVO.class);
        } catch (Exception e) {
            logger.error("数据转换出现异常!", e);
        }
        return null;
    }
}
